    //
//  RoomViewController_iPad.m
//  PokerPlus
//
//  Created by sunrui-MacBook on 11-8-9.
//  Copyright 2011 139.ME. All rights reserved.
//

#import "RoomViewController_iPad.h"

#import <QuartzCore/QuartzCore.h>

@implementation RoomViewController_iPad
@synthesize teachDelegate,btnView,table;


RoomViewController_iPad * RoomSelf;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	_textViewImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"对话框.png"]];
	[_textView addSubview:_textViewImage];
	[_textView sendSubviewToBack:_textViewImage];
	[_textView setFrame:CGRectMake(3, 768-100, 377, 93)];
	_textView.layer.cornerRadius = 8.0f;
	[btnView insertSubview:table atIndex:0];
	[self.view addSubview:btnView];
	
	socketLogin = [[AppDelegate sharedDelegate] mainsocket];
	eventLogin = [[AppDelegate sharedDelegate] eventLogin];
	
	IMP OnRefleshGameInfo = [self methodForSelector:@selector(OnRefleshGameInfo:)];
	
	[eventLogin AddCmd:hhcReflashGameInfo fun:(CMDFUN)OnRefleshGameInfo];
	RoomSelf = self;
}


- (void)buttonPressed:(UIButton *)sender{
	if (sender == backHall) {
		//[self viewDidDisappear:YES];
		[_textView resignFirstResponder];
		[UIView beginAnimations:nil context:nil];
		[UIView setAnimationDuration:0.3f];
		//[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
		self.btnView.transform=CGAffineTransformMakeScale(0.7,0.7);
		self.btnView.center = CGPointMake(512, 200);
		self.view.alpha = 0;
		[UIView commitAnimations];
		//[[AppDelegate sharedDelegate] ServerConnected:self.view];
		[teachDelegate bottomAppear];
		[table tableDisAppear];
		
		
		return;
	}
	
	if (sender == standUp) {
		NSLog(@"standup");
		return;
	}
}

- (void)viewDidAppear:(BOOL)animated{
	[super viewDidAppear:YES];
	NSLog(@"RoomView DidAppear");
	
	[table tableAppear];
}

- (void)viewDidDisappear:(BOOL)animated{
	[super viewDidDisappear:animated];
	NSLog(@"RoomView DidDisAppear");
	[table tableDisAppear];
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return YES;
}


- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}


- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

#pragma mark -

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{

	
	
	[_textViewImage setContentMode:UIViewContentModeScaleToFill];
	_textViewImage.image = [UIImage imageNamed:@"大对话框.png"];
	
	[UIView beginAnimations:nil context:nil];
	[UIView setAnimationDuration:0.3];
	table.transform=CGAffineTransformMakeScale(0.6,0.6);
	table.center = CGPointMake(755, 230);
	_textViewImage.frame = CGRectMake(0, 0, 459, 300);
	_textView.frame = CGRectMake(3, 107, 459,300);
	[UIView commitAnimations];
	
	return YES;
}
- (BOOL)textViewShouldEndEditing:(UITextView *)textView{
	
	
	[UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
		table.transform=CGAffineTransformMakeScale(1,1);
		table.center = CGPointMake(512, 384);
		_textView.frame = CGRectMake(3, 768-100, 377, 93);
	} completion:^(BOOL finished){
		
		_textViewImage.frame = CGRectMake(0, 0, 377, 93);
		//[_textViewImage setContentMode:UIViewContentModeScaleToFill];
		_textViewImage.image = [UIImage imageNamed:@"对话框.png"];
	}];
	
	return YES;
}

- (void)OnRefleshGameInfo:(SocketEngine *)socket
{
	NSLog(@"房间信息已刷新");

}

@end
